<%@ page import="com.lihuanyu.upcOA.conn.databaseUtil" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.Calendar" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="isTeaLogin.jsp"></jsp:include>
<%
  int tid = 0;
   if(session.getAttribute("tid") != null) {
    tid = Integer.parseInt(session.getAttribute("tid").toString());}
  //int tid=1;
//  Calendar a= Calendar.getInstance();
//  int year=a.get(Calendar.YEAR);
//  System.out.print(year);
  request.setCharacterEncoding("utf-8");
  String teaname = request.getParameter("teaname") == null ? "" : new String(request.getParameter("teaname"));
  String classname = request.getParameter("classname") == null ? "" : new String(request.getParameter("classname"));
  String subtime = request.getParameter("subtime") == null ? "" : new String(request.getParameter("subtime"));
  String comtime = request.getParameter("comtime") == null ? "" : new String(request.getParameter("comtime"));
  String stunum =request.getParameter("stunum") ==null ? "" :new String(request.getParameter("stunum"));
  databaseUtil db = new databaseUtil();
  String sql = "INSERT INTO `tea_subwork`(`teaname`,`classname`, `classtime`, `cmptime`, `stunum`, `tid`) " +
          "VALUES ('"+teaname+"','"+classname+"','"+subtime+"','"+comtime+"','"+stunum+"',"+tid+")";
  System.out.print(sql);
  db.executeUpdate(sql);
%>
<tr>
  <div class="col-md-1">
    <td>教师</td>
  </div>
  <div class="col-md-1">
    <td>课程</td>
  </div>
  <div class="col-md-1">
    <td>上课学时</td>
  </div>
  <div class="col-md-1">
    <td>上机学时</td>
  </div>
  <div class="col-md-1">
    <td>上课人数</td>
  </div>
</tr>

<form method="post" action="#" name="add_form">
  <tr style="display: none" class="add_row">
    <div class="col-md-1">
      <td><input type="text" name="teacher_name1" id="teaname0"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="kecheng" id="classname"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="shangke_time" id="subtime"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="shangji_time" id="comtime"></td>
    </div>
    <div class="col-md-1">
      <td><input type="text" name="stu_number" id="stunum0"></td>
    </div>
  </tr>
</form>
<%
  sql="select * from tea_subwork where tid="+tid+"";
  //System.out.print(sql);
  db.executeQuery(sql);
  ResultSet rs = db.getRs();
  while (rs.next()){
    String teachername= rs.getString(2);
    String clatime =    rs.getString(3);
    String captime =    rs.getString(4);
    String studentnum = rs.getString(5);
    String subname =    rs.getString(7);
%>
<tr class="second">
  <div class="col-md-1">
    <td><%=teachername%></td>
  </div>
  <div class="col-md-1">
    <td><%=subname%></td>
  </div>
  <div class="col-md-1">
    <td><%=clatime%></td>
  </div>
  <div class="col-md-1">
    <td><%=captime%></td>
  </div>
  <div class="col-md-1">
    <td><%=studentnum%></td>
  </div>
</tr>
<%
  }
  db.sqlclose();
%>
